<template>
    <div class="xiangqing">
        <div v-if="showList">
          <van-tabs v-model="active">
            <van-tab title="基础信息">
              <div v-if="JFData" v-for="(item, index) in fileList1" :key="index">
                <p v-if="item.title" class="subTitle" style="font-size: 18px;"><span class="line"></span>{{ item.title }}</p>
                <div v-else-if="!item.line"
                     style="display: flex;justify-content: center;align-items: center;color: black;border-bottom: 1px solid #d2d2d2;">
                  <van-field :readonly="item.isread" v-model="JFData[item.key]"
                             :label="item.label" />
                </div>
                <!--<div v-if="item.line" class="line"></div>-->
              </div>
              <div style="text-align: center;line-height: 50vh" v-if="!JFData">暂无数据</div>
            </van-tab>
            <van-tab title="巡查信息">
              <div class="middle1">
                <div v-for="(item, index) in fileList2" :key="index">
                  <p v-if="item.title" class="subTitle" style="font-size: 18px;">
                      <!--<span class="line"></span>-->
                      <span  style="color: #ff0000">*</span>
                      {{ item.title }}
                  </p>
                  <div v-else-if="item.isTime">
                    <selectPicker :disabled="disabled" :isTime="true" :labels="item.label" :placeholder="'请选择'" :selectValue="rowData[item.key]"
                                  @getMessage="setValue1"></selectPicker>
                  </div>
                  <div v-else-if="!item.isTime && !item.isDanXuan && !item.isSelect && !item.isUpload && !item.isinput"
                       style="display: flex;justify-content: center;align-items: center;color: black;border-bottom: 1px solid #d2d2d2;">
                    <van-field :disabled="disabled" :readonly="item.isread" v-model="rowData[item.key]"
                               :label="item.label" :placeholder="'请输入' + item.label" />
                  </div>
                  <div v-else-if="item.isDanXuan" style="border-bottom: 1px solid #d2d2d2;">
                            <span v-if="item.label"
                                  style="display: inline-block;padding-left: 10px;line-height: 36px;font-size: 14px;">{{
                                    item.label }}</span>
                              <span style="float: right; padding-top: 8px;padding-left: 15px;">
                                <van-radio-group v-model="rowData[item.key]" direction="horizontal" @change="radioChange">
                                    <van-radio style="margin-bottom: 5px; font-size: 14px"
                                               :disabled="disabled"
                                               v-for="(item2, index2) in item.children" :key="index2 + 'childrens'"
                                               :name="item2.value">{{ item2.name }}
                                    </van-radio>
                                </van-radio-group>
                            </span>
                  </div>
                  <div v-else-if="item.isSelect && item.isShows">
                    <selectPicker :disabled="disabled" :isTime="false"  :ISrequired="item.label==='系统施工进度'||disabled" :values="'DICNAME'" :DICID="'DICID'" :placeholder="item.label"
                                  :columns="item.NYDARR" :labels="item.label" :selectValue="newData[item.key] | inUseName(item.NYDARR)"
                                  @getMessage="setValue"></selectPicker>
                  </div>
                  <div v-else-if="item.isUpload">
                    <upLoad id="upLoad1" :disabled="disabled" :isoutFile="true" :rowData="rowData" :FJData="item.file"
                            :SHITUID="'98bcf528966e48ce896a8b3fd02d45d5'"
                            :UpLoadID="'7a3fc061c866434b8475d3775c9ddcea'" />
                  </div>
                  <div v-if="item.isinput && item.isShows">
                    <p style="margin-top: 4px; font-size: 14px;padding-left: 10px;">
                      <!--<span style="color: #ff0000">*</span>-->
                      {{ item.label }}</p>
                    <van-field :disabled="disabled" v-model="rowData[item.key]" type="textarea" label :border="false"
                               disable-default-padding
                               style="background-color: #e4e4e4; margin-top: 8px; min-height: 140px" />
                  </div>
                </div>
              </div>
              <div class="footer">
                <span v-if="($route.query.index==0 || $route.query.index==null) && !showHistoryBtn">
                   <van-button @click="handleAdd" style="margin-right: 10px;" size="small" type="info">提交</van-button>
                </span>
                <van-button v-if="!showHistoryBtn" @click="showList=false" size="small" type="info">历史巡查记录</van-button>
                <van-button v-if="showHistoryBtn" size="small"  type="info" @click="showList=false,getData2()">返回</van-button>
              </div>
            </van-tab>
          </van-tabs>
        </div>
        <div v-if="!showList" class="middle" style="overflow: auto;">
        <div class="search-list">
        <!--<div style="height: 90vh;overflow-y: auto">-->
        <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
          <div class="search-list-top" v-for="(item, index) in list" :key="index" @click="handleGoto(item)">
            <div class="top">
              <div style="float: left;"><span style="font-weight:1000;font-size: 18px;line-height: 36px;">户主姓名：{{ item.HOUSEAPPLICANT }}</span></div>
              <div style="float: right;"><span style="font-weight:1000;font-size: 18px;line-height: 36px;">巡查结论：{{ item.XCJL_DICNAME }}</span></div>
            </div>
            <div class="top1">
              <div style="font-size: 14px;float: left;width: 50%;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">
                巡查施工进度:<span style="font-weight: 500;font-size: 14px;">{{ item.XCSGJD == '635' ? '现场放样' : item.XCSGJD == '636' ? '基槽验线' :
                  item.XCSGJD == '637' ? '一层立模' : item.XCSGJD == '638' ? '竣工验收' : '暂无数据' }}</span></div>
              <div style="font-size: 14px;text-align: right;width: 50%;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">
                系统施工进度:<span style="font-weight: 500;">{{ item.XTSGJD == '635' ? '现场放样' : item.XTSGJD == '636' ? '基槽验线' :
                  item.XTSGJD == '637' ? '一层立模' : item.XTSGJD == '638' ? '竣工验收' : '暂无数据' }}</span></div>
            </div>
            <div class="top1">
              <div style="font-size: 14px;float: left;width: 50%;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">
                巡查人:<span style="font-weight: 500;">{{ item.XCR || '暂无数据' }}</span></div>
              <div style="font-size: 14px;line-height: 24px;text-align: right;width: 50%;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">
                巡查时间:<span style="font-weight: 500;">{{ item.XCSJ?item.XCSJ.substring(0, 10):'暂无数据' || '暂无数据'
                }}</span>
              </div>
            </div>
            <div class="top1">
              <div style="font-size: 14px;float: left;">地址:<span style="font-weight: 500;">{{
                item.ADDRESS ?
                item.ADDRESS : "暂无数据" }}</span></div>
            </div>
          </div>
        </van-list>
        <!--</div>-->
      </div>
        <div style="position: fixed;bottom:10px;">
            <div class="footer " style="width: 100vw;">
              <van-button @click="goBack" size="small" type="info">返回</van-button>
            </div>
          </div>
    </div>
  </div>
</template>

<script>
import dd from 'gdt-jsapi'
import upLoad from '@/utils/upLoad'
import selectPicker from '@/utils/selectPicker'
import { FileServerProxy,ExecProcedure } from '@/utils/api'
import { GJDBFunction2 } from '@/utils/queryData'
import { v4 as uuidv4 } from 'uuid'
export default {
  data() {
    return {
      disabled: false,
      showHistoryBtn: false,
      loading: false,
      finished: false,
      showList: true,
      active: 0,
      JFData: {

      },
      FJData1: [
        {
          title: '处置前照片',
          FileName: [],
          groupGuid: '5f361872-5eda-456f-9c96-c5a08ec09728',
          fileList: []
        },
        {
          title: '处置后照片',
          FileName: [],
          groupGuid: 'bc38ec98-583c-48c9-9a21-52efd719376f',
          fileList: []
        },
        {
          title: '现场照片',
          FileName: [],
          groupGuid: 'b77b5e8f-8565-4f3a-afd5-903ea9e55b78',
          fileList: []
        }],
      newData: {
        XCJL: '',
        CZZT: '',

      },
      NewROW_GUID: "",
      isreadonly: false,
      isreadonly1: true,
      rowData: {},
      fileList1: [
        {
          title: '户主信息'
        },
        {
          label: '姓名',
          key: 'HOUSEAPPLICANT',
          isread: true
        },
        {
          label: '手机号',
          key: 'APPLYPHONE',
          isread: true
        },
        {
          line: true
        },
        {
          title: '建房信息'
        },
        {
          label: '所属市',
          key: 'CITY_CITYNAME',
          isread: true
        },
        {
          label: '所属县(区)',
          key: 'COUNTY_CITYNAME',
          isread: true
        },
        {
          label: '所属镇',
          key: 'TOWN_CITYNAME',
          isread: true
        },

        {
          label: '所属村',
          key: 'VILLAGE_CITYNAME',
          isread: true
        },
        {
          label: '地址',
          key: 'ADDRESS',
          isread: true
        },
        {
          label: '建房类型',
          key: 'JFXZ',
          isread: true
        },
        {
          label: '宅基地面积(㎡)',
          key: 'ZJDMJ',
          isread: true
        },
        {
          label: '房屋占地面积(㎡)',
          key: 'FJZDMJ',
          isread: true
        },
        {
          label: '住房建筑面积(㎡)',
          key: 'JZMJ',
          isread: true
        },
        {
          label: '檐口高度(m)',
          key: 'YKGD',
          isread: true
        },
        {
          label: '建筑层数',
          key: 'JZCS',
          isread: true
        },
        // {
        //   label: '农污设施建设情况',
        //   key: 'NWSS_CITYNAME',
        //   isread: true
        // },
        {
          label: '建筑结构',
          key: 'JZJG',
          isread: true
        }
      ],
      fileList2: [
        {
          title: '巡查信息'
        },
        {
          label: '巡查时间',
          key: 'XCSJ',
          isread: false,
          isTime: true,
          isDanXuan: false
        },
        {
          label: '巡查人',
          key: 'XCR',
          isread: false,
          isDanXuan: false
        },
        {
          title: '房屋施工情况'
        },
        {
          label: '系统施工进度',
          key: 'XTSGJD',
          isread: false,
          isTime: false,
          isDanXuan: false,
          isSelect: true,
          isShows: true,
          NYDARR:  [
            {
              DICID: '635',
              DICNAME: '建筑放样'
            },
            {
              DICID: '636',
              DICNAME: '基槽验线'
            },
            {
              DICID: '638',
              DICNAME: '竣工验收'
            },
          ]
        },
        {
          label: '巡查施工进度',
          key: 'XCSGJD',
          isread: false,
          isDanXuan: false,
          isTime: false,
          isSelect: true,
          isShows: true,
          NYDARR: [
            {
              DICID: '635',
              DICNAME: '现场放样'
            },
            {
              DICID: '636',
              DICNAME: '基槽验线'
            },
            {
              DICID: '637',
              DICNAME: '一层立模'
            },
            {
              DICID: '638',
              DICNAME: '竣工验收'
            },
          ]
        },
        {
          title: '房屋审批情况'
        },
        {
          label: '悬挂施工安全牌',
          key: 'FWSP1',
          isDanXuan: true,
          children: [
            {
              name: "是",
              key: "FWSP1",
              value: 1,
            },
            {
              name: "否",
              key: "FWSP1",
              value: 2,
            },
          ],
        },
        {
          label: '按审批要求建设',
          key: 'FWSP2',
          isDanXuan: true,
          children: [
            {
              name: "是",
              key: "FWSP2",
              value: 1,
            },
            {
              name: "否",
              key: "FWSP2",
              value: 2,
            },
          ],
        },
        {
          title: '安全管理情况'
        },
        {
          label: '使用钢制脚手架',
          key: 'AQGL1',
          isDanXuan: true,
          children: [
            {
              name: "是",
              key: "liveStoneIsError",
              value: 1,
            },
            {
              name: "否",
              key: "liveStoneIsCrack",
              value:2,
            },
          ],
        },
        {
          label: '佩戴安全帽',
          key: 'AQGL2',
          isDanXuan: true,
          children: [
            {
              name: "是",
              key: "liveStoneIsError",
              value: 1,
            },
            {
              name: "否",
              key: "liveStoneIsCrack",
              value: 2,
            },
          ],
        },
        {
          label: '使用安全网',
          key: 'AQGL3',
          isDanXuan: true,
          children: [
            {
              name: "是",
              key: "liveStoneIsError",
              value: 1,
            },
            {
              name: "否",
              key: "liveStoneIsCrack",
              value: 2,
            },
          ],
        },
        {
          label: '设置警示标志',
          key: 'AQGL4',
          isDanXuan: true,
          children: [
            {
              name: "是",
              key: "liveStoneIsError",
              value: 1,
            },
            {
              name: "否",
              key: "liveStoneIsCrack",
              value: 2,
            },
          ],
        },
        {
          label: '配备灭火器',
          key: 'AQGL5',
          isDanXuan: true,
          children: [
            {
              name: "是",
              key: "liveStoneIsError",
              value: 1,
            },
            {
              name: "否",
              key: "liveStoneIsCrack",
              value: 2,
            },
          ],
        },
        {
          label: '使用配电箱',
          key: 'AQGL6',
          isDanXuan: true,
          children: [
            {
              name: "是",
              key: "liveStoneIsError",
              value: 1,
            },
            {
              name: "否",
              key: "liveStoneIsCrack",
              value: 2,
            },
          ],
        },
        {
          title: '其他问题'
        },
        {
          label: '其他问题',
          key: 'QTWT',
          isShows: true,
          isinput: true,
          isSelect: false
        },
        {
          title: '初步判断'
        },
        {
          label: '',
          key: 'CBPD1',
          isDanXuan: true,
          children: [
            {
              name: "基本安全(当有以上情况处于正常情况下)",
              key: "CBPD1",
              value: 1,
            },
            {
              name: "存在安全隐患(当存在一条及以上异常情况)",
              key: "CBPD1",
              value: 2,
            },
          ],
        },
        {
          title: '巡查结论'
        },
        {
          label: '巡查结论',
          key: 'XCJL',
          isread: true,
          isShows: true,
          isDanXuan: false,
          isSelect: true,
          NYDARR: [
            {
              DICNAME: '正常施工',
              DICID: '654'
            },
            {
              DICNAME: '违章施工',
              DICID: '653'
            }
          ]
        },
        {
          label: '处置状态',
          key: 'CZZT',
          isShows: false,
          isread: true,
          isDanXuan: false,
          isSelect: true,
          NYDARR: [
            {
              DICNAME: '已处置',
              DICID: '651'
            },
            {
              DICNAME: '未处置',
              DICID: '652'
            }
          ]
        },
        {
          label: '处置情况',
          key: 'CZQK',
          isShows: false,
          isinput: true,
          isSelect: false
        },
        // {
        //   title: '巡查照片'
        // },
        {
          label: '巡查照片',
          key: 'name',
          isread: false,
          isDanXuan: false,
          isSelect: false,
          isUpload: true,
          file: [
            // {
            //   title: '现场照片',
            //   groupGuid: '现场照片',
            //   FileName: [],
            //   fileList: [],
            // }
          ]
        }
      ],
      list: []
    }
  },
  filters: {
    inUseName: function (msg, data) {
      let name = ''
      data.forEach(item => {
        if (item.DICID == msg) {
          name = item.DICNAME
        }
      })
      return name
    }
  },
  created() {

    // this.getData()
    // //已巡查
    // if (this.$route.query.index != 0) {
    //   this.getXCInFo()
    // }else{
    //   this.rowData.ROW_GUID = uuidv4()
    // }

  },
  mounted() {
    if (this.$route.query.index == 0 || this.$route.query.index == null) {
      // 未巡查
      this.disabled = false
      this.rowData.ROW_GUID = uuidv4()
    } else {
      // 已巡查

      this.disabled = true
      this.getXCInFo()
    }
    this.cityCode = this.$route.query.cityCode
    let obj = JSON.parse(this.$route.query.data)
    console.log(obj)
    this.rowData.XCSJ = this.getDate(true)
    this.rowData.XCR = JSON.parse(window.localStorage.getItem('userName')).userName
    if (obj.WF_NAME) {
      this.fileList2[4].NYDARR.forEach((item,index)=>{
        if (item.DICNAME===obj.WF_NAME) {
          this.newData.XTSGJD = item.DICID
          this.rowData.XTSGJD = item.DICID
        }
      })
    }
    this.rowData.CITY = obj.CITY
    // this.rowData.ROW_GUID = obj.ROW_GUID
    this.rowData.TO_ROW_GUID = obj.TO_ROW_GUID
    if (obj.SFXC==1) {
      console.log(obj)
      for (let i in obj) {
        if (obj[i] && isNaN(Number(obj)[i], 10) || obj[i] == 0) {
          obj[i] = obj[i].toString()
        }
        if (obj[i]) {
          this.rowData[i] = obj[i]
          this.rowData.XCSJ = this.rowData.XCSJ?this.rowData.XCSJ.substring(0, 10):''
        }
      }

    }


    this.getData()
    dd.ready(function () {
      dd.setTitle({
        title: '施工巡查'
      })
        .then((res) => { })
        .catch((err) => {
          console.error(err)
        })
    })
  },
  methods: {
    handleGoto(item) {
      // let XCJL = item.XCJL == '653'?'正常施工':'违章施工'
      this.rowData.PATROLS_ROW_GUID = item.PATROLS_ROW_GUID
      // this.isShowsData(XCJL)
      this.getXCInFo()
      this.getData()
      this.showHistoryBtn = true
    },
    goBack() {
      if (this.$route.query.index == 0 || this.$route.query.index == null) {
        this.disabled = false
        this.cityCode = this.$route.query.cityCode
        if (this.rowData.SFXC==1) {
          this.rowData = JSON.parse(this.$route.query.data)
        } else {
          for (let i in this.rowData) {
            this.rowData[i] = null
          }
        }
        for (let i in this.newData) {
          this.newData[i] = ""
        }
        this.fileList2[this.fileList2.length-1].file = []
        this.rowData.WF_NAME = JSON.parse(this.$route.query.data).WF_NAME
        if (this.rowData.WF_NAME) {
          this.fileList2[4].NYDARR.forEach((item,index)=>{
            if (item.DICNAME===this.rowData.WF_NAME) {
              this.newData.XTSGJD = item.DICID
              this.rowData.XTSGJD = item.DICID
            }
          })
        }
        this.rowData.XCSJ = this.getDate(true)
        this.rowData.XCR = JSON.parse(window.localStorage.getItem('userName')).userName
        this.rowData.CITY = JSON.parse(this.$route.query.data).CITY
        this.rowData.TO_ROW_GUID = JSON.parse(this.$route.query.data).TO_ROW_GUID
        this.getData()
        this.rowData.ROW_GUID = uuidv4()
        this.showList = true
        this.showHistoryBtn = false
      } else {
        this.getXCInFo()
        // this.disabled = true
        // this.showList = true
        this.showHistoryBtn = false
      }


    },
    async onLoad() {
      this.pageNum += 1
      this.getData2()
    },
    //获取历史巡查记录
    async getData2() {
      let rowguid = JSON.parse(this.$route.query.data).ROW_GUID
      let searchObject = [{ "field": 'ROW_GUID', "value": rowguid }]
      let data = {
        "accessCode": "688bd3883572440a859dfd8ba9194e7b",
        "cityCode": this.cityCode ? this.cityCode : window.localStorage.getItem('citycode'),
        "params": {
          "dataguid": "03360cdb-88b9-475e-9455-dfb302f39129",
          "searchObject": JSON.stringify(searchObject),
          "token": window.localStorage.getItem('token')
        }
      }
      const res = await FileServerProxy(data)
      this.num = JSON.parse(res.data.data).Data.length
      this.list = JSON.parse(res.data.data).Data;
      console.log(this.list)
      this.loading = false
      this.finished = true
    },
    setValue(value, name, label) {
      debugger
      this.isShowsData(value)
      if (value == '违章施工' || value == '正常施工') {
        this.rowData.XCJL = name
      } else if (value == '已处置' || value == '未处置') {
        this.rowData.CZZT = name
      } else if (label == '系统施工进度') {
        this.rowData.XTSGJD = name
      } else if (label == '巡查施工进度') {
        this.rowData.XCSGJD = name
      }
    },
    setValue1(name, value) {
      this.rowData.XCSJ = name
    },
    isShowsData(value) {
      let type = this.rowData.CZZT == '651' ? '已处置' : '未处置'
      if (value == '违章施工') {
        this.fileList2.forEach(item => {
          if (item.label == '处置状态' || item.label == '处置情况') {
            item.isShows = true
          } else if (item.label == '巡查照片' ) {
            item.file = []
          }
          // else if (item.label == '巡查照片'&& this.rowData.CZZT=="652") {
          //   item.file = [
          //     {
          //       title: '处置前照片',
          //       groupGuid: '处置前照片',
          //       FileName: [],
          //       fileList: [],
          //     },
          //     {
          //       title: '处置后照片',
          //       groupGuid: '处置后照片',
          //       FileName: [],
          //       fileList: [],
          //     }
          //   ]
          // }
        })
        // && this.rowData.CZZT=="651"
        if (type == '已处置') {
          this.fileList2.forEach(item => {
            if (item.label == '处置状态' || item.label == '处置情况') {
              item.isShows = true
            } else if (item.label == '巡查照片') {
              item.file = [
                {
                  title: '处置前照片',
                  groupGuid: '5f361872-5eda-456f-9c96-c5a08ec09728',
                  FileName: [],
                  fileList: [],
                  isReadOnly:true
                },
                {
                  title: '处置后照片',
                  groupGuid: 'bc38ec98-583c-48c9-9a21-52efd719376f',
                  FileName: [],
                  fileList: [],
                  isReadOnly:true
                }
              ]
            }
          })
        } else if (type == '未处置'){
          this.fileList2.forEach(item => {
            if (item.label == '处置情况') {
              item.isShows = false
            } else if (item.label == '巡查照片') {
              item.file = []
            }
          })
        }
      } else if (value == '正常施工') {
        this.fileList2.forEach(item => {
          if (item.label == '处置状态' || item.label == '处置情况') {
            item.isShows = false
          }
          else if (item.label == '巡查照片') {
            item.file = [
              {
                title: '现场照片',
                groupGuid: 'b77b5e8f-8565-4f3a-afd5-903ea9e55b78',
                FileName: [],
                fileList: [],
                isReadOnly:true
              },
            ]
          }
        })
      }
      if (value == '已处置') {
        this.fileList2.forEach(item => {
          if (item.label == '处置状态' || item.label == '处置情况') {
            item.isShows = true
          } else if (item.label == '巡查照片') {
            item.file = [
              {
                title: '处置前照片',
                groupGuid: '5f361872-5eda-456f-9c96-c5a08ec09728',
                FileName: [],
                fileList: [],
                isReadOnly:true
              },
              {
                title: '处置后照片',
                groupGuid: 'bc38ec98-583c-48c9-9a21-52efd719376f',
                FileName: [],
                fileList: [],
                isReadOnly:true
              }
            ]
          }
        })
      } else if (value == '未处置'){
        this.fileList2.forEach(item => {
          if (item.label == '处置情况') {
            item.isShows = false
          } else if (item.label == '巡查照片') {
            item.file = []
          }
        })
      }
        },
    async handleAdd() {
      debugger
      let me = this;
      //先判断有没有填写必填项
      let add = true
      me.fileList2.forEach((item, index) => {
        if (item.key) {
          if (me.rowData.XCJL == '654') {
            if (item.key !== 'CZZT' && item.key !== 'CZQK' && item.key !== 'name') {
              if (!me.rowData[item.key]) {
                // console.log(item.key)
                add = false
                me.$toast.fail('请填写必填项！')
                return
              }
            }
            if (item.label === "巡查照片") {
              if (item.file[0].fileList.length === 0) {
                add = false
                me.$toast.fail('请上传巡查照片！')
                return
              }
            }
          } else {
            if (item.key !== 'name' && item.key !== 'CZQK' ) {
              if (!me.rowData[item.key]) {
                // console.log(item.key)
                add = false
                me.$toast.fail('请填写必填项！')
                return
              }
            }
            // this.rowData.CZZT == '651' ? '已处置' : '未处置'
            if (item.label === "巡查照片" && this.rowData.CZZT == '651') {
              if (item.file[0].fileList.length === 0 || item.file[1].fileList.length === 0) {
                add = false
                me.$toast.fail('请上传处置照片！')
                return
              }
            }
          }
        }
      })
      delete me.rowData.PKID;
      if (add) {
        debugger
        const data = {
          "accessCode": "0fb3f6123d1b4fe6851c99532c463f6f",
          "cityCode": this.cityCode,
          "params": {
            "dataGuid": "8eb4caea-ecf5-45cf-827c-98a7a10be226",
            "strParams": JSON.stringify([me.rowData])
          }
        }
        const res1 = await FileServerProxy(data)
        let result = JSON.parse(res1.data.data).Success
        if (result) {
          console.log()
          if (me.rowData.XCSGJD == 638) {
            me.updateMainInfo();
            // me.updateData(me.rowData.ROW_GUID)
          }
          me.$toast.success('提交成功')
          me.$router.push({
            path: '/ConstructionInspection',
          })
        } else {
          me.$toast.fail('提交失败')
        }
      }

    },
    async updateData(id){
      // let data = {
      //   procName: 'up_updateSFXC',
      //   dtParams: [{"ROW_GUID":id}]
      //
      // }
      await GJDBFunction2('up_updateSFXC', [{ "ROW_GUID": id }],this.cityCode)
      // const res = await ExecProcedure(JSON.stringify(data))
      // console.log(res)
    },
    async updateMainInfo() {
      let me = this;
      //修改主表
      // await GJDBFunction2('up_updateSFXC', [{ "IN_ROW_GUID": me.rowData.TO_ROW_GUID }],this.cityCode)
      let paer1 = {
        procName: 'up_updateSFXC',
        dtParams: JSON.stringify([{ "IN_ROW_GUID": me.rowData.TO_ROW_GUID }]),
        token: window.localStorage.getItem("token"),
      };
      let procNamesk1 = {
        accessCode: "69db6bece3a7480592e2ec753d1e335e",
        cityCode: this.cityCode,
        params: paer1,
      };
      const reskh1 = await FileServerProxy(procNamesk1);
      },
    radioChange(name) {
      //需要根据房屋审批情况和安全管理情况来自动赋值给初步判断
      // let newobj = {
      //     FWSP1:'',
      //     FWSP2:'',
      //     AQGL1:'',
      //     AQGL2:'',
      //     AQGL3:'',
      //     AQGL4:'',
      //     AQGL5:'',
      //     AQGL6:'',
      // }
      // let index = true
      // for(let i in newobj){
      //     if(this.rowData[i] == '1'){
      //         index = false
      //     }
      // }
      // if(!index) {
      //     this.rowData.CBPD1 = '0'
      // } else {
      //     this.rowData.CBPD1 = '1'
      // }
      // this.$forceUpdate()
    },
    //获取回显数据
    async getData() {
      let rowguid = JSON.parse(this.$route.query.data).ROW_GUID
      //"field":"to_row_guid","value":"0d3e7459-5c5f-47e4-86b8-930f881a9ee8"
      let searchObject = [{ "field": 'ROW_GUID', "value": rowguid }]
      let data = {
        "accessCode": "688bd3883572440a859dfd8ba9194e7b",
        "cityCode": this.cityCode ? this.cityCode : window.localStorage.getItem('citycode'),
        "params": {
          "dataguid": "d9829ac6-e75e-4bb4-82e9-3b98403036ae",
          "searchObject": JSON.stringify(searchObject),
          "token": window.localStorage.getItem('token')
        }
      }
      const res = await FileServerProxy(data)
      if (JSON.parse(res.data.data).Data.length>0) {
        this.JFData = JSON.parse(res.data.data).Data[0]
        if (this.JFData.JZCS) {
          switch (this.JFData.JZCS) {
            case "552":
              this.JFData.JZCS="一层"
              break
            case "553":
              this.JFData.JZCS="二层"
              break
            case "554":
              this.JFData.JZCS="三层"
              break
            case "555":
              this.JFData.JZCS="四层"
              break
            case "556":
              this.JFData.JZCS="五层"
              break
            case "557":
              this.JFData.JZCS="六层"
              break
            case "558":
              this.JFData.JZCS="七层"
              break
            case "559":
              this.JFData.JZCS="八层"
              break
            case "560":
              this.JFData.JZCS="九层"
              break
            case "561":
              this.JFData.JZCS="十层"
              break

          }
        }
        if (this.JFData.JFXZ) {
          switch (this.JFData.JFXZ) {
            case 12:
              this.JFData.JFXZ = "原址翻建"
              break
            case 13:
              this.JFData.JFXZ = "改扩建"
              break
            case 14:
              this.JFData.JFXZ = "异址新建"
              break
            case 643:
              this.JFData.JFXZ = "其他"
              break
          }
        }
        if (this.JFData.JZJG) {
          switch (this.JFData.JZJG) {
            case 42:
              this.JFData.JZJG = "框架结构"
              break
            case 43:
              this.JFData.JZJG = "砖混结构"
              break
            case 44:
              this.JFData.JZJG = "木结构"
              break
            case 163:
              this.JFData.JZJG = "其他"
              break
            case 1101:
              this.JFData.JZJG = "钢结构"
              break
          }
        }
      }
    },
    //获取巡查信息
    async getXCInFo() {
      let searchObject = [{ "field": 'ROW_GUID', "value": this.rowData.PATROLS_ROW_GUID?this.rowData.PATROLS_ROW_GUID:JSON.parse(this.$route.query.data).PATROLS_ROW_GUID}]
      let data = {
        "accessCode": "688bd3883572440a859dfd8ba9194e7b",
        "cityCode": this.cityCode ? this.cityCode : window.localStorage.getItem('citycode'),
        "params": {
          "dataguid": "8eb4caea-ecf5-45cf-827c-98a7a10be226",
          "searchObject": JSON.stringify(searchObject),
          "token": window.localStorage.getItem('token')
        }
      }
      const res = await FileServerProxy(data)
      // debugger
      console.log(JSON.parse(res.data.data))
      if (res.data.data) {
        if (JSON.parse(res.data.data).Data.length>0) {
          this.rowData = JSON.parse(res.data.data).Data[JSON.parse(res.data.data).Data.length-1];
          this.isShowsData(this.rowData.XCJL== '654' ? '正常施工' : '违章施工')
          this.newData.CZZT = this.rowData.CZZT
            // ?this.rowData.CZZT == '651' ? '已处置' : '未处置':''
          this.newData.XCJL = this.rowData.XCJL
            // ?this.rowData.XCJL == '653' ? '正常施工' : '违章施工':''
          this.newData.XTSGJD = this.rowData.XTSGJD
          this.newData.XCSGJD = this.rowData.XCSGJD
          this.rowData.XCSJ = this.rowData.XCSJ?this.rowData.XCSJ.substring(0, 10):''
          this.$nextTick(()=>{
            this.showList = true
            this.disabled = true
          })
        }
      }
    },
  },
  components: {
    upLoad,
    selectPicker
  }
}
</script>


<style lang="scss" scoped>
.xiangqing {
  width: 100%;
  height: 100vh;
  /*padding: 6px;*/
  /*font-size: 13px;*/

  .subTitle {
    width: 100%;
    height: 40px;
    line-height: 40px;
    font-size: 18px;
    position: relative;
    display: flex;
    align-items: center;
    /*border-bottom: 1px solid #9b9b9b;*/
    padding-left: 10px;
    font-weight: bold;
    color: #3f8ffc;
    .line {
      width: 6px;
      height: 26px;
      background: #3f8ffc;
      display: inline-block;
      margin-right: 10px;
    }
  }

  .line {
    width: 100%;
    height: 10px;
    background-color: #f6f6f6;
  }

  .middle1 {
    height: 87vh;
    overflow-y: auto !important;
    /*font-weight: 560;*/
  }

  .middle {
    padding: 10px;

    .search-list {
      height: 90vh;

      .search-list-top {
        overflow: auto;
        background-color: #fff;
        /*border-radius: 8px;*/
        /*padding: 8px;*/
        border-bottom: 1px solid #ebedf0;
        // box-shadow: 0 3px 3px rgba(0, 0, 0, 0.2);
        margin-bottom: 8px;

        .top {
          display: flex;
          justify-content: space-between;
          line-height: 36px;
        }

        .top1 {
          display: flex;
          justify-content: space-between;
          line-height: 24px;
        }

        .bottom {
          display: flex;
          justify-content: space-between;
          line-height: 24px;
        }
      }
    }
  }

  .footer {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 10px;

  }
}
</style>


<style>
.xiangqing .van-field__label {
  color: black;
  width: 8em;
}

.xiangqing .van-field__control {
  text-align: right;
}

.xiangqing .van-radio--horizontal {
  margin-right: 30px;
}
</style>
